package org.fanpeng.demo.design;

import org.fanpeng.demo.design.cuisine.ICuisine;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.ArrayList;
import java.util.List;

/**
 * className: XiaoEr
 * Description:
 * date: 2021/9/9 11:03
 *
 * @author fanpeng
 * @version 1.0
 */
public class XiaoEr {

    private Logger logger = LoggerFactory.getLogger(XiaoEr.class);

    private List<ICuisine> cuisines = new ArrayList<>();

    public void order(ICuisine iCuisine) {
        cuisines.add(iCuisine);
    }

    public synchronized void placeOrder() {
        for (ICuisine cuisine : cuisines) {
            cuisine.cook();
        }
        cuisines.clear();
    }

}
